﻿using System;
using fastCSharp;

namespace diantou.web.tutorial
{
    /// <summary>
    /// 教程列表
    /// </summary>
    [fastCSharp.code.cSharp.webView(IsPool = true, IsReferer = false)]
    partial class list : web.view<list>
    {
        /// <summary>
        /// 教程列表
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        private userTutorial[] tutorials;
        /// <summary>
        /// 教程列表
        /// </summary>
        /// <param name="page">分页号</param>
        /// <returns>是否成功</returns>
        private bool loadView(int page, bool isSelf)
        {
            diantou.dataAccess.tutorial[] values;
            if (isSelf)
            {
                if (currentUser == null)
                {
                    AjaxResponse(webConfig.NotFound404);
                    return false;
                }
                values = diantou.dataAccess.clientCache.Tutorial.Get(diantou.dataAccess.tcpCall.focusTutorial.getFocusIds(currentUser.Id, dataModel.focus.type.Register));
            }
            else
            {
                values = diantou.dataAccess.clientCache.Tutorial.Get(diantou.dataAccess.tcpCall.tutorial.getShowIds(pageInfo.Size = fastCSharp.config.pub.Default.PageSize, pageInfo.Page = page, currentUserId, currentUser != null && currentUser.IsChangeVisit, out pageInfo.Count));
                if (requestHeader.IsSearchEngine) pageInfo.Path = diantou.dataModel.path.pub.Default.TutorialListPath;
            }
            tutorials = values.getArray(value => new userTutorial { Tutorial = value, User = currentUser });
            return true;
        }
    }
}
